//
//  FeedBackViewController.m
//  QuicklyPlay
//
//  Created by lanou3g on 15/11/1.
//  Copyright © 2015年 OPteam. All rights reserved.
//

#import "FeedBackViewController.h"
#import <BmobSDK/Bmob.h>


@interface FeedBackViewController ()

@property (strong, nonatomic) IBOutlet UITextField *feedbackTextField;
@property (strong, nonatomic) IBOutlet UITextField *emailTextField;


@end

@implementation FeedBackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    [[GestureRecognizerTool creatScreenEdgePanGestureRecognizerLeftWithViewController:self] addTarget:self action:@selector(BackToSettingViewController:)];
    
    

} 

//返回上一个控制器 SettingViewConeroller
- (IBAction)BackToSettingViewController:(UIBarButtonItem *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil] ;
    
}


- (IBAction)sendAction:(UIBarButtonItem *)sender {
    
    BmobObject *feedbackObj = [[BmobObject alloc] initWithClassName:@"Feedback"];
    
    //联系方式
    [feedbackObj setObject:self.emailTextField.text forKey:@"contact"];
    
    //反馈内容
    [feedbackObj setObject:self.feedbackTextField.text forKey:@"content"];
    
    [feedbackObj saveInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) {
        if (isSuccessful) {
            
            UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您的反馈信息已经提交咯" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            
            [a show];
            self.emailTextField.text = @"";
            self.feedbackTextField.text = @"" ;
            
            
            NSLog(@"保存成功");
        }else{
            NSLog(@"保存失败");
        }
    }];
}






// 点击空白处实现键盘的返回
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
